﻿using Absky.Business.SystemManage;
using Absky.Entity.SystemManage;
using Absky.Util;
using Absky.Web.Controllers;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Absky.Web.Areas.SystemModule.Controllers
{
    [Area("SystemModule")]
    public class MenuController : BaseController
    {
        private readonly MenuBLL _menuBll = new MenuBLL();

        /// <summary>
        /// 获取功能模块数据列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetMenuList()
        {
            var data = await _menuBll.GetList(null);
            if(data.Code == Enum.ResultCodeEnum.Success)
            {
                return Json(new Result<List<MenuEntity>>(Enum.ResultCodeEnum.Success, data.Data));
            }
            else
            {
                return Json(new Result(Enum.ResultCodeEnum.Fail, data.Message));
            }
        }
        #region 权限数据
        /// <summary>
        /// 获取权限按钮和列表信息
        /// </summary>
        /// <param name="url">页面地址</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetAuthorizeButtonColumnList(string url)
        {
            Dictionary<string, string> dicButton = new Dictionary<string, string>();
            Dictionary<string, string> dicColumn = new Dictionary<string, string>();
            Dictionary<string, string> dicForm = new Dictionary<string, string>();

            var jsonData = new
            {
                module = new Dictionary<string,string>(),
                btns = dicButton,
                cols = dicColumn,
                forms = dicForm
            };
            return Json(jsonData);
        }
        #endregion
    }
}
